<?php   
/*
    Plugin Name:主题设置  
    Plugin URI:https://www.zuifengyun.com  
    Description:主题后台设置  
    Version:1.0  
    Author:HuiSir
    Author URI:https://www.zuifengyun.com
*/ 
function theme_setting(){
	add_theme_page(__('<inject themeName />主题设置'),__('<inject themeName />主题设置'),'edit_themes',basename(__FILE__),'setting_function');
	add_action('admin_init', 'register_theme_setting');
}
function register_theme_setting(){
	register_setting('settings_form','theme_options');
}
add_action('admin_menu','theme_setting');
function setting_function(){?>
	<div class="wrap">
		<h2><inject themeName />主题设置</h2>
		<h4>感谢您使用正版的WordPress<code><inject themeName />主题</code>，您的当前版本为<code><?php $my_theme = wp_get_theme();echo $my_theme->get( 'Version' );?></code>，作者：<a href="//www.zuifengyun.com/" target="_blank">HuiSir</a></h4>
		<h5>主题后续版本更新，请移步 <inject themeInfoLink /> 查看主题最新版本及获取后续更新服务。也可添加作者微信：HuiSir01</h5>
		<?php
			if( $_GET['settings-updated']){
				echo '<div id="message" class="updated fade"><p><strong> 主题设置已保存 </strong></p></div>';
			}
			if( 'reset' == isset($_REQUEST['reset']) ) {
				delete_option('theme_options');
				echo '<div id="message" class="updated fade"><p><strong> 主题设置已重置 </strong></p></div>';
			}
			 //加载上传图片
			wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox');  
		?>
		<p class="description" id="tagline-description">以下设置图片的选项，需要点击上传按钮上传本地图片或选择媒体库图片，然后点击<code>插入到文章</code>即可拷贝到文本框内</p>
		<form method="post" action="options.php">
			<?php settings_fields('settings_form'); ?>
			<?php $options=get_option('theme_options'); ?>
			<table class="form-table">
                <tbody>
				<tr>
					<th scope="row">网站LOGO</th>
					<td><input type="url" class="regular-text code" name="theme_options[logo_img]" value="<?php echo $options['logo_img']; ?>" /><input type="button" class="button button-primary" name="logo_img_button" value="上传" id="upbottom1" style="margin-left:10px"/><p class="description" id="tagline-description">高度为32像素</p></td>
                </tr>
				<tr>
					<th scope="row">网站LOGO(移动端)</th>
					<td><input type="url" class="regular-text code" name="theme_options[logo_img_sm]" value="<?php echo $options['logo_img_sm']; ?>" /><input type="button" class="button button-primary" name="logo_img_sm_button" value="上传" id="upbottom2" style="margin-left:10px"/><p class="description" id="tagline-description">高度为24像素</p></td>
				</tr>
				<tr>
					<th scope="row">底部手机访问二维码</th>
					<td><input type="url"  class="regular-text code" name="theme_options[mobile-qrcode]" value="<?php echo $options['mobile-qrcode']; ?>" /><input type="button" class="button button-primary" name="mobile-qrcode_button" value="上传" id="upbottom3" style="margin-left:10px"/><p class="description" id="tagline-description">130*130像素</p></td>
                </tr>
				<tr>
					<th scope="row">微信打赏二维码</th>
					<td><input type="url"  class="regular-text code" name="theme_options[weixin_qrcode]" value="<?php echo $options['weixin_qrcode']; ?>" /><input type="button" class="button button-primary" name="weixin_qrcode_button" value="上传" id="upbottom4" style="margin-left:10px"/><p class="description" id="tagline-description">190*190像素</p></td>
                </tr>
				<tr>
					<th scope="row">支付宝打赏二维码</th>
					<td><input type="url"  class="regular-text code" name="theme_options[alipay_qrcode]" value="<?php echo $options['alipay_qrcode']; ?>" /><input type="button" class="button button-primary" name="alipay_qrcode_button" value="上传" id="upbottom6" style="margin-left:10px"/><p class="description" id="tagline-description">190*190像素</p></td>
                </tr>
				<tr>
					<th scope="row">备案号</th>
					<td><input type="text" class="regular-text" name="theme_options[beian_record]" value="<?php echo $options['beian_record']; ?>" /><p class="description" id="tagline-description">请输入您网站的备案号用于底部显示，可留空</p></td>
                </tr>
				<tr>
					<th scope="row">首页描述（Description）</th>
					<td><fieldset>
					<p>请输入你的网站描述，一般不超过200个字符</p>
					<p><textarea name="theme_options[site_description]" rows="8" cols="60" id="theme_options[site_description]" class="code"><?php echo $options['site_description']; ?></textarea></p>
		            </fieldset></td>
                </tr>
				<tr>
					<th scope="row">首页关键词（KeyWords）</th>
					<td><fieldset>
					<p>请输入你的网站关键词，一般不超过100个字符，每个词用英文逗号隔开</p>
					<p><textarea name="theme_options[site_keywords]" rows="4" cols="60" id="theme_options[site_keywords]" class="code"><?php echo $options['site_keywords']; ?></textarea></p>
		            </fieldset></td>
                </tr>
				<tr>
					<th scope="row">内页底部版权声明</th>
					<td><fieldset>
					<p>请输入你的网站声明，请注意不要超过90个汉字</p>
					<p><textarea name="theme_options[cr_notice]" rows="4" cols="60" id="theme_options[cr_notice]" class="code"><?php echo $options['cr_notice']; ?></textarea></p>
		            </fieldset></td>
                </tr>
				<tr>
					<th scope="row">流量统计代码</th>
					<td><fieldset>
					<p>这里放置您的统计代码。如百度统计、站长统计等</p>
					<p><textarea name="theme_options[tj_code]" rows="8" cols="60" id="theme_options[tj_code]" class="code"><?php echo $options['tj_code']; ?></textarea></p>
		            </fieldset></td>
                </tr>
				</tbody>
			</table>
			<h3 class="title">更新服务</h3><p>您享有该主题的后续更新服务以及BUG修复服务，更新可联系微信：HuiSir01</p>
			<h3 class="title">二次开发</h3><p>主题二次开发为有偿服务，您可添加作者微信：HuiSir01</p>
			<h3 class="title">声明</h3><p>版权所有，翻版必究。禁止本主题转卖和改版转卖。您可将主题进行任何形式的修改或转送他人，但恳请保留主题底部的版权。</p><p>制作一款主题不容易，作者为斟酌主题样式和代码付出了无数的不眠夜和汗水，请尊重作者的辛苦劳动。</p>
            <?php submit_button(); ?>
		</form>
		<form method="post">
			<p>注意：以下操作将会删除您的所有设置</p>
			<p class="submit"><input type="submit" name="reset" class="button button-primary" value="重置主题"/><input type="hidden" name="reset" value="reset" /></p>
		</form>
		<div class="clear"></div>
	</div>
	<script type="text/javascript">
	jQuery(document).ready(function(){jQuery('#upbottom1,#upbottom2,#upbottom3,#upbottom4,#upbottom5,#upbottom6').click(function(){targetfield=jQuery(this).prev('.regular-text');tb_show('','media-upload.php?type=image&amp;TB_iframe=true');return false});window.send_to_editor=function(html){imgurl=jQuery('img',html).attr('src');jQuery(targetfield).val(imgurl);tb_remove()}});
	</script>
<?php } ?>